<?php
    $zona = $this->zona;
    $this->title = $zona;
    $this->headTitle($this->title);

    require_once "models/Db/Gallery_db.php";
    $club = new Gallery_db();

    $pivaList = $this->pivaList;
    $discoList = $this->discoList;
    $eventList = $this->eventList;

    $allDisco = $this->allDisco;
    $zonaList = $this->zonaList;
?>

<?php
/**
 *  dispay all disco in  sponsor0
 */
$line = '<div id="box">';
foreach ($allDisco as $key=>$allDisco2){
    $line_new = '<h2><a href="'. $this->url(array('controller'=>'Club',
                                                  'name'=> $allDisco2[0],
                                                   ), 'locale', TRUE) .'">' . $allDisco2[1]
              . '</a></h2>';
    $line = $line . $line_new;
    }
$line = $line . '</div>';
$this->layout()->sponsor0 = $line;

/**
 * dispay all "zone" in  zone
 */
$line4 = '';
foreach ($zonaList as $key=>$zonaList2){
    $line4_new = '<h2><a href="'. $this->url(array('controller'=>'Index',
                                                    'action'=>'provincia',
                                                    'id'=> $zonaList2,
                                                   ), 'index', TRUE) .'">' . $zonaList2 . '</a></h2>';
    $line4 = $line4 . $line4_new;
    }
$line4 = $line4 . '';
$this->layout()->provincia = $line4;


require_once "models/Utility/Utility.php";
$utility_obj = new Utility();
require_once "models/Db/Event_db.php";
$eventHandle = new Event_db();

echo "<h1>Locali in provincia di $zona</h1>";
?>
<table>
<tr>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
</tr>
<?php foreach($pivaList as $disco) :
        $club_logo = $club->getDiscoImgThumbPath($disco['piva']);
        $name_disco = $eventHandle->getUniqueNamebyPiva($disco['piva']);
?>
<tr class="club_list">
    <td><img src="<?php echo $club_logo; ?>" alt="<?php echo $name_disco['name']; ?>" /></td>
    <td><?php echo $name_disco['name']; ?></td>
    <td class="view_event"><a class="event" href="<?php echo $this->url(array('controller'=>'Index',
                                             'action'=>'eventi',
                                             'id'=>$name_disco['unique_name'] ),
                                                   'index', true);?>">
            <span class="club_link_span"><br />&nbsp;&nbsp;Eventi</span></a>
    </td>
    <td class="club_page"><a class="club_link_b" href="<?php echo $this->url(array('controller'=>'Club',
                                             'action'=>'show-club-info',
                                             'name'=>$name_disco['unique_name'],
                                             ),
                                                    'locale', true);?>">
            <span class="club_link_span">Club page</span></a>
    </td>
</tr>
<?php endforeach; ?>
</table>

<h2>Eventi nell'area di <?php echo $zona ?></h2>
<p id="catpicker"></p>
<?php
$eventHandle = new Event_db();
if ($eventList==0) {

} else {
    foreach ($eventList as $discoElement){
        //usa event_db per recuperare il nome
        $piva = $discoElement['piva'];
        $id_evento = $discoElement['id'];

        $discoName3 = $eventHandle->getNameDsicoByPiva($piva);
        $thumb = $eventHandle->getThumbByID($id_evento);
        $thumb_path = $thumb['thumb_path'];
        $titolo_evento = $discoElement['titolo'];
        $html_descrizione = html_entity_decode($discoElement['descrizione']);
        $descrizione = $utility_obj->trim_body(strip_tags($html_descrizione), 100);
        $data = $discoElement['data_inizio'];
?>
<a id="discount-item_a"href="#" >
    <div class="discounted-item <?php
                                    echo str_replace(" ", "", trim($discoName3['name'])) ?>" rel="<?php
                                    echo $this->url(array(
                                                        'controller'=>'Index',
                                                        'action'=>'evento',
                                                        'id'=>"0_" . $id_evento), 'index', TRUE);
                                    ?>">
        <img src="/<?php 
                        echo $thumb_path
                    ?>" alt="flayer" />
        <div class="reasonbar">
            <div class="prod-title" style="width: 70%;"><?php 
                                                            echo $titolo_evento
                                                        ?></div>
            <div class="reason" style="width: 29%;"><span class="dname"><?=$discoName3['name']?></span> <?=$data?></div>
        </div>
        <div class="discount-bar">
            <?php echo $descrizione; ?>
        </div>
    </div>
</a>
<?php
    }//end foreach
}//end if
//echo "</form>";
?>